package com.iotp.service.crop_type;

import com.iotp.dao.crop_type.CropTypeMapper;
import com.iotp.entity.crop_type.CropType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.xml.ws.ServiceMode;
import java.util.List;

@Service("cropTypeService")
public class CropTypeServiceImpl implements CropTypeService {
    @Autowired
    private CropTypeMapper cropTypeMapper;

    @Override
    public Long add(CropType cropType) {
        this.cropTypeMapper.insert(cropType);
        return cropType.getId();
    }

    @Override
    public void update(CropType cropType) {
        this.cropTypeMapper.updateByPrimaryKeySelective(cropType);
    }

    @Override
    public void delete(Long id) {
        this.cropTypeMapper.deleteByPrimaryKey(id);
    }

    @Override
    public CropType queryById(Long id) {
        return this.cropTypeMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<CropType> queryList(CropType cropType) {
        return cropTypeMapper.selectByCondition(cropType);
    }
}
